package com.rc.web.controller;

import com.mybatisflex.core.paginate.Page;
import com.rc.common.annotate.ApiLog;
import com.rc.pojo.dto.farmapply.AddFarmApplyDTO;
import com.rc.pojo.dto.farmapply.ApprovalFarmApplyDTO;
import com.rc.pojo.dto.farmapply.FarmApplyPageQuery;
import com.rc.pojo.vo.farmapply.PageFarmApplyVO;
import com.rc.web.service.FarmApplyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 *  控制层。
 *
 * @author 27806
 * @since 2024-06-18
 */
@RestController
@RequestMapping("/farmApply")
@RequiredArgsConstructor
@Api(tags = "加盟")
@Validated
public class FarmApplyController {
    private final FarmApplyService farmPlayService;

    @PostMapping
    @ApiOperation("申请加盟")
    public void add(@RequestBody AddFarmApplyDTO dto){
        farmPlayService.add(dto);
    }

    @PutMapping("/approval")
    @ApiOperation("超级管理员审批加盟")
    @ApiLog
    public void approval(@RequestBody  ApprovalFarmApplyDTO dto){
        farmPlayService.approval(dto);
    }

    @GetMapping("/page")
    @ApiOperation("分页查看申请加盟")
    public Page<PageFarmApplyVO> getPage(FarmApplyPageQuery dto){
        return farmPlayService.getPage(dto);
    }
}
